﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Base;
using System.Linq;
using System.Threading;
using DTO;
using BLL;

namespace CRM.GUI.QLCuocGoi
{
    public partial class frmCallDetailIB : DevExpress.XtraEditors.XtraForm
    {
    //    private List<ResultStatusEntity> listRSE;
        private string _incomingnumber;
        public frmCallDetailIB(string incomingnumber)
        {         
            //CallManagement cm = new CallManagement();
            InitializeComponent();
            //cmbSachet.Enabled = false;
            //cmbBooklet.Enabled = false;
            //listRSE = SharedData.ResultStatusList;
            _incomingnumber = incomingnumber;
            IntialLoad();
       //     CallMonitor.GetNum = new CallMonitor.IncomingCallHandler(IncomingCallHandle);
        }

   //     private BLsupervisor sup = new BLsupervisor();
   //     private UserInfoEntity us = new UserInfoEntity();
   //     private BLcallagent ca = new BLcallagent();
   ////     private LoadCustomerFunc cus = new LoadCustomerFunc();
   //     private CallManagement cm = new CallManagement();
   //     private long CusID;

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //DateTime? DoB = new DateTime();
            //DateTime? EDD = new DateTime();
            //int WC = 0, DC = 0, PC = 0;
            //if (dtpEDD.Text != "")
            //    EDD = DateTime.ParseExact(dtpEDD.Text, "dd/MM/yyyy", null);
            //if (dtpDoBMom.Text != "")
            //    DoB = DateTime.ParseExact(dtpDoBMom.Text, "dd/MM/yyyy", null);
            //if (cmbWard.SelectedValue != null)
            //    WC = int.Parse(cmbWard.SelectedValue.ToString());
            //if (cmbDistrict.SelectedValue != null)
            //    DC = int.Parse(cmbDistrict.SelectedValue.ToString());
            //if (cmbProvince.SelectedValue != null)
            //    PC = int.Parse(cmbProvince.SelectedValue.ToString());
            //cus.UpdateCustomer(
            //            CusID,
            //            txtFirstName.Text,
            //            txtLastName.Text,
            //            txtNote.Text,
            //            EDD.GetValueOrDefault(),
            //            txtEDDTR.Text,
            //            txtIDNumber.Text,
            //            DoB.GetValueOrDefault(),
            //            txtHomeNumber.Text,
            //            txtSubStreet.Text,
            //            txtStreet.Text,
            //            (int)WC,
            //            (int)DC,
            //            (int)PC,
            //            txtHomePhone.Text,
            //            txtOfficePhone.Text,
            //            txtCellPhone.Text,
            //            cmbCurrentBrand.Text,
            //            cmbPreviousBrand.Text,
            //            us.UserID
            //            );
        //    MessageBox.Show("Cập nhật thành công!");
        }

        private void cmbDistrict_SelectionChangeCommitted(object sender, EventArgs e)
        {
            // Tự động load phường xã theo quận huyện
            //cmbWard.DataSource = sup.loadphuongxa((int)cmbDistrict.SelectedValue);
            //cmbWard.DisplayMember = "RegionName";
            //cmbWard.ValueMember = "Region_Code";
        }

        private void cmbProvince_SelectionChangeCommitted(object sender, EventArgs e)
        {
            // Tự động load quận huyện theo tỉnh thành
            //int provincecode = (int)cmbProvince.SelectedValue;
            //cmbDistrict.DataSource = SharedData.RegionList.Where(a => a.Parent_Code == provincecode).ToList();
            //cmbDistrict.DisplayMember = "RegionName";
            //cmbDistrict.ValueMember = "Region_Code";
            //// Tự động load phường xã theo quận huyện
            //int districtcode = (int)cmbDistrict.SelectedValue;
            //cmbWard.DataSource = SharedData.RegionList.Where(a => a.Parent_Code == districtcode).ToList();
            //cmbWard.DisplayMember = "RegionName";
            //cmbWard.ValueMember = "Region_Code";
        }

        private void cmbProvince_Click(object sender, EventArgs e)
        {
            //cmbProvince.DataSource = SharedData.RegionList.Where(a => a.RegionLevel == 2).ToList();
            //cmbProvince.DisplayMember = "RegionName";
            //cmbProvince.ValueMember = "Region_Code";
        }

        private void cmbCurrentBrand_Click(object sender, EventArgs e)
        {
            //cmbCurrentBrand.DataSource = ca.LoadListBrand();
            //cmbCurrentBrand.DisplayMember = "StatusName";
            //cmbCurrentBrand.ValueMember = "Status_Code";
        }

        private void cmbPreviousBrand_Click(object sender, EventArgs e)
        {
            //cmbPreviousBrand.DataSource = ca.LoadListBrand();
            //cmbPreviousBrand.DisplayMember = "StatusName";
            //cmbPreviousBrand.ValueMember = "Status_Code";
        } 

        private void grdViewTaskCA_RowClick(object sender, RowClickEventArgs e)
        {
            
        }


        private void ShowRecord()
        {
        //    grdRecord.DataSource = cm.getHistoryCall(CusID);
        }

     //   private List<SampleDetailEntity> data;

        private void ShowSample()
        {
            //data = cm.getListSample(CusID);
            //grdSample.DataSource = this.BindingContext[data];
            //grdSample.DataSource = data;
        }



        private void cmbBooklet_Click(object sender, EventArgs e)
        {
            //cmbBooklet.DataSource = cm.getBooklet();
            //cmbBooklet.DisplayMember = "Sample_Code";
            //cmbBooklet.ValueMember = "Sample_Code";
        }

        private void cmbSachet_Click(object sender, EventArgs e)
        {
            //cmbSachet.DataSource = cm.getSachet();
            //cmbSachet.DisplayMember = "Sample_Code";
            //cmbSachet.ValueMember = "Sample_Code";
        }

        private void cmbResultGroup_SelectionChangeCommitted(object sender, EventArgs e)
        {
            //cmbResultDetail.Properties.DataSource = GetResultStatusDetail((int)cmbResultGroup.SelectedValue);
            //cmbResultDetail.Properties.DisplayMember = "Result_Code";
            //cmbResultDetail.Properties.ValueMember = "Result_Code";
        }

        //private List<ResultStatusEntity> GetResultStatusDetail(int value)
        //{
        //    //List<ResultStatusEntity> list = new List<ResultStatusEntity>();
        //    //List<ResultStatusEntity> listCha = listRSE.Where(a => a.Parent_Code == value).ToList();
        //    //foreach (var item in listCha)
        //    //{

        //    //}
        //    //return list;
        //}

        private void grdViewRecord_RowCellClick(object sender, RowCellClickEventArgs e)
        {
            //var data = (RecordEntity) grdViewRecord.GetRow(e.RowHandle);            
            //if (e.Column == grdViewRecord.Columns[0])
            //{
            //    cm.DownloadFileRecord(data.RecordLink);
            //    MessageBox.Show("Đã download xong!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.None);
            //}
        }

        //private void IncomingCallHandle(string incomingnumber)
        //{
        //    MessageBox.Show(incomingnumber);
        //}

        private void IntialLoad()
        {
            txtCellPhone.Text = _incomingnumber;
        }

    }
}